{% extends "layouts/base.html" %}

{% block title %} Target Domain {% endblock %} 


<!-- Specific Page CSS goes HERE  -->
{% block stylesheets %}{% endblock stylesheets %}

{% block content %}
{{ target_file }}
<style>
.tfp-1 {
  background-color: white;
}
.tfp0 {
  background-color: gray;
}
.tfp1 {
  background-color: orange;
}
</style>

<table width="100%">
 <tr>
 <td>
<form class="navbar-form" action="alerts" method="post">
 			{%csrf_token%}
             <span class="bmd-form-group"><div class="input-group no-border">
             <input type="text" name='alerts_filter_search' class="form-control" placeholder="Search by Finding Name">
			 <input type="hidden" name="alerts_filter" value="filter">
			 
             <button type="submit" class="btn btn-white btn-round btn-just-icon" rel="tooltip" title="" data-original-title="Search">
             <i class="material-icons">search</i>
             <div class="ripple-container"></div>
             </button>
             </div></span>
</form>
 </td>
 <tr>
  <td>
    <form action="alerts" method="post">
      {%csrf_token%}
      <input type="hidden" name="alerts_download" value="filter">
      <button type="submit" class="btn btn-white btn-round btn-just-icon" rel="tooltip" title data-original-title="Download Results">
        <i class="material-icons">system_update_alt</i>
      </button>




    </form>
  </td>
 </tr>
	
</td>
</tr>
</table>
<!-- End Pager  -->

        <div class="row">
            <div class="col-md-12">
              <div class="card">
                <div class="card-header card-header-primary">
                  <h4 class="card-title ">Findings List</h4>
                </div>
                <div class="card-body">
                  <div class="table-responsive">
                    <table class="table">
                      <thead class="text-primary">
                        <th>
                          Finding
                        </th>
                        <th>
                          URL
                        </th>
                        <th>
                          Severity
                        </th>                        
                        <th>
                          Description
                        </th>
                        <th>
                          IP Address
                        </th>
                        <th>
                          Last Seen
                        </th>
                        <th>
                          Count
                        </th>
                        <th>
                          Action
                        </th>
                      </thead>
                      <tbody>
                        <form  class="navbar-form" action="alerts" method="post">
                          {%csrf_token%}
                          <input type="hidden" name='vd_action'>
                        {% for finding in findings %}
                        <tr>
                          <td  >
                            {{ finding.info.name }}
                          </td>
                          <td>
                            {{ finding.host }}
                          </td>
                          <td>
                            {{ finding.info.severity }}
                          </td>
                          <td>
                            {{ finding.info.description }}
                          </td>
                          <td>
                            {{ finding.ip }}
                          </td>
                          <td>
                            {{ finding.timestamp |slice:":10"}}
                          </td>    
                          <td>
                            {{ finding.counter}}
                            <!--{{ finding.counter }}-->
                          </td>  
                          {% if finding.jira_ticket %}
                          <td>
                            <a href={{finding.jira_url}} target="_blank">{{finding.jira_ticket}}</a>
                                                    
                          </td>
                          {% else %}
                          {%if jira_settings %}
                          <td>
                            <select name="finding_form", class="selectalert">
                              <option selected="selected" disabled>Select Action</option>
                              <option value="take_action,{{finding.timestamp}},{{finding.info.name}},{{finding.host}}">Submit</option>
                              <option value="ignore,{{finding.timestamp}},{{finding.info.name}},{{finding.host}}">Ignore</option>
                              <option value="delete,{{finding.timestamp}},{{finding.info.name}},{{finding.host}}">Delete</option>
                            </select>
                             </td>
                          {% else %}
                          <td>
                            <select name="finding_form", class="selectalert">
                            <option selected="selected" disabled>Select Action</option>
                            <option value="delete,{{finding.timestamp}},{{finding.info.name}},{{finding.host}}">Delete</option>
                          </select>
                          </td>   
                          {% endif %}
                          {% endif %}
                        
                        </tr>

{% endfor %}
                      </tbody>
                      <button type="submit">Submit for Action</button><b>{{message}}</b>
                    </form>
                    </table>
                  </div>
                </div>
              </div>
            </div>


 {% if findings.has_other_pages %}   
  <ul class="pagination">
    {%if findings.has_previous %}
        <li><a href="?page={{findings.previous_page_number }}">Previous</a></li>
    {% else %}
        <li class="disabled"><span>Previous</span></li>
    {% endif %}
    {% for i in findings.paginator.page_range %}
      {% if findings.number == i %}
        <li class="active"><span>{{ i }} <span class="sr-only">(current)</span></span></li>
      {% else %}
        <li><a href="?page={{ i }}">{{ i }}</a></li>
      {% endif %}
    {% endfor %}
    {% if findings.has_next %}
      <li><a href="?page={{ findings.next_page_number }}">Next</a></li>
    {% else %}
      <li class="disabled"><span>Next</span></li>
    {% endif %}
  </ul>
{% endif %}        
{% endblock content %}

<!-- Specific Page JS goes HERE  -->
{% block javascripts %}{% endblock javascripts %}
